package com.potenza.training.interview.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.interview.dao.InterviewFeedbackDao;
import com.potenza.training.interview.entity.InterviewFeedbackEntity;
import com.potenza.training.interview.service.InterviewFeedbackService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("interviewFeedbackService")
public class InterviewFeedbackServiceImpl extends ServiceImpl<InterviewFeedbackDao, InterviewFeedbackEntity> implements InterviewFeedbackService {

    @Autowired
    InterviewFeedbackDao interviewFeedbackDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<InterviewFeedbackEntity> page = this.page(
                new Query<InterviewFeedbackEntity>().getPage(params),
                new QueryWrapper<InterviewFeedbackEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public InterviewFeedbackEntity findByinvitationId(Integer id, Integer uid) {
        QueryWrapper<InterviewFeedbackEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(InterviewFeedbackEntity::getUid,uid);
        queryWrapper.lambda().eq(InterviewFeedbackEntity::getInvitationId,id);
        return interviewFeedbackDao.selectOne(queryWrapper);
    }

}